package day04;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

public class Demo06 {

	public static void main(String[] args) {


		Collection<PersonS> c1 = new HashSet<PersonS>();
		Collection<PersonS> c2 = new HashSet<PersonS>();
		c1.add(new PersonS("Tom", 21));
		c1.add(new PersonS("Jerry", 21));

		c2.add(new PersonS("Aody", 21));
		c2.add(new PersonS("John", 21));

		boolean b = c1.addAll(c2);
//		System.out.println(b);
//		System.out.println(c1);

//		b = c1.addAll(c2);
//		System.out.println(b);
//		System.out.println(c1);
//
//		b = c1.containsAll(c2);
//		System.out.println(b);
//		System.out.println(c1);

		PersonS[] p = new PersonS[c1.size()];
		Iterator it = c1.iterator();
		for (int i = 0; i < p.length; i++) {

			while (it.hasNext()) {
				p[i] = (PersonS) it.next();
				System.out.println(p[i]);
			}
		}

	}

}
